package com.xy.biz.ts.domain.converter;

import java.util.Collection;
import java.util.List;

import com.xy.biz.ts.domain.req.*;
import com.xy.tool.util.BeanUtilsEx;
import com.xy.biz.ts.domain.bo.ExaminationPaperBO;
import com.xy.biz.ts.domain.po.ExaminationPaperPO;
import com.xy.biz.ts.domain.query.ExaminationPaperQuery;
import com.xy.biz.ts.domain.resp.GetExaminationPaperResponse;
import com.xy.biz.ts.domain.req.examinationPaper.ListExaminationPaperRequest;

/**
 *
 *
 * @author wcs
 * @date 2021-3-8
 */
public class ExaminationPaperConverter {

    public static ExaminationPaperPO toPO(ExaminationPaperBO source) {
        return BeanUtilsEx.copyProperties(source, () -> new ExaminationPaperPO(), true);
    }

    public static List<ExaminationPaperPO> toPO(Collection<ExaminationPaperBO> source) {
        return BeanUtilsEx.copyPropertiesForNewList(source, () -> new ExaminationPaperPO(), true);
    }

    public static ExaminationPaperBO fromPO(ExaminationPaperPO source) {
        return BeanUtilsEx.copyProperties(source, () -> new ExaminationPaperBO());
    }

    public static List<ExaminationPaperBO> fromPO(Collection<ExaminationPaperPO> source) {
        return BeanUtilsEx.copyPropertiesForNewList(source, () -> new ExaminationPaperBO());
    }

    public static ExaminationPaperBO toBO(SaveExaminationPaperRequest source) {
        return BeanUtilsEx.copyProperties(source, () -> new ExaminationPaperBO(), true);
    }

    public static ExaminationPaperBO toBO(UpdateExaminationPaperRequest source) {
        return BeanUtilsEx.copyProperties(source, () -> new ExaminationPaperBO(), true);
    }

    //固定试题
    public static ExaminationPaperBO toBO(SaveFixedExaminationPaperRequest source) {
        return BeanUtilsEx.copyProperties(source, () -> new ExaminationPaperBO(), true);
    }

    public static ExaminationPaperBO toBO(EditFixedExaminationPaperRequest source) {
        return BeanUtilsEx.copyProperties(source, () -> new ExaminationPaperBO(), true);
    }

    //随机试题
    public static ExaminationPaperBO toBO(SaveRandomExaminationPaperRequest source) {
        return BeanUtilsEx.copyProperties(source, () -> new ExaminationPaperBO(), true);
    }

    public static ExaminationPaperBO toBO(EditRandomExaminationPaperRequest source) {
        return BeanUtilsEx.copyProperties(source, () -> new ExaminationPaperBO(), true);
    }

    public static List<ExaminationPaperBO> toBO(Collection<SaveExaminationPaperRequest> source) {
        return BeanUtilsEx.copyPropertiesForNewList(source, () -> new ExaminationPaperBO(), true);
    }

    public static GetExaminationPaperResponse toResponse(ExaminationPaperBO source) {
        return BeanUtilsEx.copyProperties(source, () -> new GetExaminationPaperResponse());
    }

    public static List<GetExaminationPaperResponse> toResponse(Collection<ExaminationPaperBO> source) {
        return BeanUtilsEx.copyPropertiesForNewList(source, () -> new GetExaminationPaperResponse());
    }

    public static ExaminationPaperQuery toQuery(ListExaminationPaperRequest source) {
        if (null == source) {
            return null;
        }
        ExaminationPaperQuery target = new ExaminationPaperQuery(source.getPageIndex(), source.getPageSize());
        BeanUtilsEx.copyProperties(source, target);
        return target;
    }

    public static ExaminationPaperBO toBO(RefineFixedExaminationPaperRequest source) {
        return BeanUtilsEx.copyProperties(source, () -> new ExaminationPaperBO(), true);
    }
}
